/*
-----------------------------------------------------------------------------
This source file is part of Labor3D
(Labor 3D Graphics Engine)

Copyright (c) 2009-2020 Rock Mao
* creator : Rock Mao
* created : 2009-6-27   22:29
* filename: LaborD3D10Helps.cpp
-----------------------------------------------------------------------------
*/

#include "LaborD3D10Helps.h"
NAMESPACE_LABOR3D_BEGIN

//---------------------------------------------------------------------
D3D10_USAGE CLD3D10Helps::_getUsage(EHB_Usage mUsage)
{
	if (_isDynamic(mUsage))
	{
		return D3D10_USAGE_DYNAMIC;
	}
	else
	{
		return D3D10_USAGE_DEFAULT;
	}
}

//---------------------------------------------------------------------
DXGI_FORMAT CLD3D10Helps::_getIndexType(eLIndexType eIdxType )
{
	if ( IT_16BIT == eIdxType )
		return DXGI_FORMAT_R16_UINT;
	else
		return DXGI_FORMAT_R32_UINT;
}

//---------------------------------------------------------------------
D3D10_USAGE CLD3D10Helps::_getUsage(int mUsage)
{
	return D3D10_USAGE_DEFAULT;
}

//---------------------------------------------------------------------
bool CLD3D10Helps::_isDynamic(EHB_Usage mUsage)
{
	switch ( mUsage)
	{
	case HBU_DYNAMIC:
	case HBU_DYNAMIC_WRITE_ONLY:
	case HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE:
		return true;
	}

	return false;
}

//---------------------------------------------------------------------
UINT CLD3D10Helps::_getAccessFlags(int mUsage)
{
	return 0;
}
//---------------------------------------------------------------------
UINT CLD3D10Helps::_getAccessFlags(EHB_Usage mUsage)
{
	if (_isDynamic(mUsage))
	{
		return D3D10_CPU_ACCESS_WRITE;
	}
	else
	{
		return 0;
	}
}

//---------------------------------------------------------------------
UINT CLD3D10Helps::_getBufferBindFlag(eLHardwareBufferType _type )
{
	UINT _bindFlag = D3D10_BIND_VERTEX_BUFFER;
	switch( _type )
	{
	case eL_VERTEX_BUFFER:
		_bindFlag = D3D10_BIND_VERTEX_BUFFER;
		break;
	case eL_INDEX_BUFFER:
		_bindFlag = D3D10_BIND_INDEX_BUFFER;
		break;
	case eL_CONSTANT_BUFFER:
		_bindFlag = D3D10_BIND_CONSTANT_BUFFER;
		break;
	default:
		break;
	}
	return _bindFlag;
}

NAMESPACE_LABOR3D_END